package ift605.EquationWithAgent.server.agent;

import jade.core.Agent;
import jade.domain.DFService;
import jade.domain.FIPAException;
import jade.domain.FIPAAgentManagement.DFAgentDescription;
import jade.domain.FIPAAgentManagement.ServiceDescription;

// Mother class of any agent that resolve derivate
public abstract class DeriveSlaveAgent extends Agent{
	private static final long serialVersionUID = -5808947299078211481L;

	public abstract Class<?> GetDeriveClass();
	
	protected void setup() {
		super.setup();
		try {
			//Register the agent to the DIRECTORY FOLDER
			DFAgentDescription dfd = new DFAgentDescription();
			dfd.setName(getAID());
			ServiceDescription sd = new ServiceDescription();
			sd.setType(GetDeriveClass().getSimpleName().toString());
			sd.setName(GetDeriveClass().getSimpleName().toString());
			dfd.addServices(sd);
			DFService.register(this, dfd);
			System.out.println(getLocalName()+" REGISTERED WITH THE DF");
		} catch (FIPAException e) {
			e.printStackTrace();
		}
	}
}
